package com.example.xdzx.service;

import com.example.xdzx.mapper.BugMapper;
import com.example.xdzx.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(rollbackFor = Exception.class)
public class BugService {
    @Autowired
    BugMapper bugMapper;
    @Autowired
    UserService userService;

    /**
     * 添加bug反馈
     * @param userId
     * @param imformation
     * @param imageUrl
     * @param callBack
     * @return
     */
    public Boolean addFeedback(Long userId,String imformation,String imageUrl,String callBack){
        try{
            // 根据userId 查询用户信息
            User user= userService.getUserById(userId);
            bugMapper.addFeedback(userId,user.getUsername(),imformation,imageUrl,callBack);
        }catch (Exception e){
            return false;
        }
        return true;
    }
}
